home *** CD-ROM | disk | FTP | other *** search
/ BBS Toolkit / BBS Toolkit.iso / rbbs_pc / vote171a.zip / VOTE171A.DOC < prev    next >
Text File  |  1988-10-23  |  14KB  |  348 lines

  1.                    *****************************************
  2.                    *             V O T E 1 7 1 A           *
  3.                    *             ---------------           *
  4.                    *               Release 1.0             *
  5.                    *              October  1988            *
  6.                    *                                       *
  7.                    *            A STARWARE PRODUCT         *
  8.                    *                   by                  *
  9.                    *             John Zimmerman            *
  10.                    *               DARK  STAR              *
  11.                    *             (707) 429-8218            *
  12.                    *****************************************
  13.  
  14.  
  15. FUNCTION AND PURPOSE OF VOTE171A
  16. --------------------------------
  17.  
  18. This is a modification to RBBS 17-1A which permits callers to vote on speci-
  19. fic topics. A current tally of votes and percentages on each topic is main-
  20. tained for viewing. Callers may vote only once on each topic. VOTE provides a
  21. very quick and easy method for Sysops to determine caller preferences and
  22. views. Prior to RBBS 171A, VOTE employed the unused 'V' command to invoke it.
  23. 'V' is now used in 171A to V)iew conference mail. Assuming that most Sysops
  24. do not have CD ROMS, and therefore do not use the Library Menu command '@',
  25. the code has been modified to use this command to call VOTE.
  26.  
  27. MODIFICATIONS AND FILES
  28. -----------------------
  29.  
  30. VOTE is implemented through the VOTE subprogram added to RBBSSUB1.BAS. While
  31. this adds to the size of RBBS code, it results in a very fast implementaion
  32. of a Voting routine, as compared to the use of a Door. The only change required
  33. to RBBS-PC.BAS is to replace the three lines at 1283 with the two lines
  34. contained later in this document.
  35.  
  36. The easiest way to insert this code is to use a memory resident text editor
  37. which has a cut and paste function. Sidekick is excellent for this purpose,
  38. as you can mark off the code contained in this document and insert it
  39. directly into the RBBS files. This modification was compiled using Quick-
  40. Basic 3.0.
  41.  
  42. Critical to the operation of VOTE are the following files which you must
  43. create. Samples of the files are included. The files are:
  44.  
  45.     VOTE      This is the menu of available voting ballots. It must be
  46.               created similar to MENU5. In other words, whatever number
  47.               or letter you want your caller to enter to select a ballot
  48.               must be by itself.
  49.  
  50.     VOTEx     Where x is a number (i.e. VOTE1). This file is the descriptive
  51.               portion of the voting ballot. It contains the title of the
  52.               ballot and a description of the issue to be voted on.
  53.  
  54.     VOTECx    Where x is a number (i.e. VOTEC1). This file contains the
  55.               different choices on the ballot, as well as the current
  56.               count. The format of the file must be:
  57.  
  58.                    "this is the name of the choice",0
  59.  
  60.              The entry enclosed in quotes is the choice description. The
  61.              number after the comma is the current number of votes for that
  62.              choice. When creating this file, set all votes to 0.
  63.  
  64.              You may have a maximum of 15 choices on each ballot. Make sure
  65.              that the number of the VOTECx files corresponds to the number
  66.              of the VOTEx file.
  67.  
  68.     VOTUSEx  This file is automatically created by the code. It is a sequen-
  69.              tial file which contains the name of each caller who voted on
  70.              a specific ballot. This file is read each time a ballot is se-
  71.              lected to prevent callers from voting more than once on the
  72.              same topic.
  73.  
  74. You can have 99 voting ballots, each ballot requiring a VOTEx, VOTECx and a
  75. VOTEUSEx file. Keep in mind that deletion of ballots will require erasing
  76. 3 files and changing VOTE - therefore, it is recommended that you keep the
  77. number of different ballots to a minimum. Note that IBM and ANSI graphics
  78. VOTE and VOTEx files can be created by adding G and C at the end as with
  79. other RBBS text files. For example, VOTE9C is an ANSI display of Ballot 9.
  80.  
  81. In addition to the files described, you will want to modify MENU2 to change
  82. @)Library to @)Vote. You may also wish to replace the '@' with a different
  83. command through CONFIG. '$' may be a good choice, because Voting means
  84. Elections, and Elections cost a lot of $$$$'s! You may also want to create
  85. a M@.HLP file to explain the operation of Vote.
  86.  
  87.  
  88. REPORTING PROBLEMS
  89. ------------------
  90.  
  91. Any problems or suggestions should be addressed to me as a C)omment on
  92. DARK STAR. DARK STAR is available 24 hours per day, 7 days per week at
  93. 300/1200/2400 baud. Keep your modem on autodial - DARK STAR supports
  94. on-line games and the line is quite busy.
  95.  
  96.  
  97. CREDITS
  98. -------
  99.  
  100. The idea for VOTE and its basic operation is derived from the DIMENSI BBS
  101. written by Carey Nachenberg and Gregory Bass. Their source code was studied,
  102. changed and enhanced for operation in RBBS. I'd also like to express my
  103. appreciation to Tom Mack, Ken Goosens, Jon Martin, and the other Sysops who
  104. make RBBS what it is. While there are many good BBS packages available,
  105. only RBBS provides the kind of flexibility and power inherent in software
  106. which allows you to modify the source code.
  107.  
  108.  
  109.  
  110. BUGS, FIXES AND ENHANCEMENTS
  111.  
  112. 02/12/88   Voting on a ballot choice greater than 9 resulted in ballot choice
  113.            1 getting the vote because in line 64720 the variable B$, which
  114.            contained the number of the selection being voted on, only had the
  115.            left most character read. Changing this to LEFT$(B$,2) allows ballot
  116.            choices greater than 9 to get the vote.
  117.  
  118.            A line showing the total votes in a specific ballot was added.
  119.  
  120. 05/15/88   Documentation updated for compatibility with RBBS 16-1A.
  121.  
  122. 10/23/88   Code modified for RBBS 17-1A. Eliminates ability to use the
  123.            @)Library command. Also includes addition of TurboKey patches
  124.            to make it work consistently with the rest of RBBS.
  125.  
  126. MODIFICATIONS TO RBBS SOURCE CODE
  127.  
  128. -----------------------------------------------------------------------------
  129. TO RBBS-PC.BAS:   Apply the changes/additions identified by ' Vote
  130. -----------------------------------------------------------------------------
  131. 1270 Z$ = B$(ANS.INDEX)
  132.      CALL ALLCAPS (Z$)
  133.      IF Z$ = "C" THEN _
  134.         Z$ = "M" : _
  135.         GOTO 5323
  136.      ON INSTR(QUIT.LIST$,Z$) GOTO 1275,1280,1285,10570,1283
  137.      GOTO 1260
  138. 1275 MENU.INDEX = 3
  139.      GOTO 1295
  140. 1280 MENU.INDEX = 2
  141.      GOTO 1295
  142. 1283 CALL VOTE(ACTIVE.USER.NAME$,USER.GRAPHIC.DEFAULT$)               'Vote
  143.      RETURN                                                           'Vote
  144. '1283 MENU.INDEX = 6                                                  'Vote
  145. '     ACTIVE.FMS.DIRECTORY$ = ""                                      'Vote
  146. '     GOTO 1295                                                       'Vote
  147. 1285 MENU.INDEX = 4
  148. 1295 CALL SETSECT
  149.      RETURN
  150. 1300 CALL QTPUT ("Message base " + GRN$,1)
  151.      RETURN
  152.  
  153. -----------------------------------------------------------------------------
  154. TO RBBSSUB1.BAS:   Add the VOTE subprogram after the PUTWORK subprogram at
  155.                    line 59660 and before the Error handling routines beginning
  156.                    at 65000
  157. -----------------------------------------------------------------------------
  158.  
  159. 59660 SUB PUTWORK (STRNG$,REC.NUM,REC.LEN) STATIC
  160.       ON ERROR GOTO 65000
  161.       FIELD #2,REC.LEN AS UPLOAD.RECORD$
  162.       LSET UPLOAD.RECORD$ = STRNG$
  163.       REC.NUM = REC.NUM + 1
  164.       PUT #2,REC.NUM
  165.       END SUB
  166.  
  167.  
  168. ' $SUBTITLE:  'VOTE   -- subroutine for voting'
  169. ' $PAGE
  170. '
  171. '  SUBROUTINE NAME    -- VOTE                   By John Zimmerman
  172. '                                               DARK STAR (707) 429-8218
  173. '
  174. '  INPUT PARAMETERS   -- PARAMETER              MEANING
  175. '
  176. '                        ACTIVE.USER.NAME$      NAME OF THE CURRENT USER
  177. '                        USER.GRAPHIC.DEFAULT$  USER'S GRAPHICS SETTING
  178. '
  179. '  OUTPUT PARAMETERS  -- NONE
  180. '
  181. '  SUBROUTINE PURPOSE -- TO DISPLAY A VOTING BALLOT, CAPTURE AND SAVE THE
  182. '                        USER'S VOTE.
  183. '
  184.  
  185.    SUB VOTE (ACTIVE.USER.NAME$,GRAPHIC.DEFAULT$) STATIC
  186.    REDIM CHOICE$(15),CHOICE.TOTAL(15)
  187.  
  188. ' *****************************************************************************
  189. ' *  OPEN THE VOTE MENU FILE AND DISPLAY AVAILABLE VOTING BALLOTS             *
  190. ' *****************************************************************************
  191.  
  192. 64700 FILE.NAME$ = "VOTE"
  193.       STOP.INTERRUPTS = FALSE
  194.       CALL GRAPHIC (GRAPHIC.DEFAULT$)
  195.       CALL BUFFILE (FILE.NAME$,X)
  196.       IF NOT OK THEN _
  197.          CALL QTPUT("No voting ballots are available",1) : _
  198.          EXIT SUB
  199.       A$ = "Vote on which ballot (Press [ENTER] to quit)"
  200.       SUBROUTINE.PARAMETER = 1
  201.       CALL TGET
  202.       IF B$ = "" THEN _
  203.          EXIT SUB
  204.       ANS.INDEX = 1
  205.       Z$ = B$(ANS.INDEX)
  206.       CALL WORDINFILE (FILE.NAME$,Z$,FOUND)
  207.       IF NOT FOUND THEN _
  208.          CALL QTPUT ("No such ballot "+Z$,1) : _
  209.          GOTO 64700
  210.       FILE.NAME$ = "VOTE" + Z$
  211.       STOP.INTERRUPTS = FALSE
  212.       CALL GRAPHIC (GRAPHIC.DEFAULT$)
  213.       CALL BUFFILE (FILE.NAME$,X)
  214.       IF NOT OK THEN _
  215.          CALL UPDTCALR ("Missing ballot " + Z$,2) : _
  216.          CALL QTPUT ("Ballot (" + Z$ + ") is not available.",1) : _
  217.          GOTO 64700
  218.       VOTE.COUNT$ = "VOTEC" + Z$
  219.       VOTE.USER$ = "VOTUSE" + Z$
  220. ' *****************************************************************************
  221. ' *  OPEN THE VOTE.COUNT$ FILE TO GET THE CHOICES AND COUNTS                  *
  222. ' *****************************************************************************
  223.  
  224. 64705 CLOSE 2
  225.       OPEN VOTE.COUNT$ FOR INPUT AS #2
  226.       CHOICES  = 0
  227.       I = 0
  228.       DO WHILE NOT EOF(2)
  229.          I = I + 1
  230.          IF I > 15 THEN _
  231.          EXIT DO
  232.          INPUT #2, CHOICE$(I),CHOICE.TOTAL(I)
  233.          CHOICE$(I) = LEFT$(CHOICE$(I),55)
  234.          CHOICES = I
  235.       LOOP
  236.       CLOSE 2
  237.  
  238. ' *****************************************************************************
  239. ' *  OPEN THE VOTE.USER$ FILE TO CHECK FOR PREVIOUS VOTE BY THE CALLER        *
  240. ' *****************************************************************************
  241.  
  242. 64710 FILE.NAME$ = VOTE.USER$
  243.       CALL FINDIT(FILE.NAME$)
  244.       IF NOT OK THEN _
  245.          GOTO 64715
  246.       CLOSE 2
  247.       OPEN VOTE.USER$ FOR INPUT AS #2
  248.       VOTED = 0
  249.       DO WHILE NOT EOF(2)
  250.          INPUT #2, I$
  251.          IF ACTIVE.USER.NAME$ = I$ THEN
  252.             VOTED = 1
  253.             EXIT DO
  254.          END IF
  255.       LOOP
  256.       CLOSE 2
  257.       IF VOTED = 1 THEN
  258.          A$ = "You already voted on this ballot. See the results ([Y],N)"
  259.          SUBROUTINE.PARAMETER = 1
  260.          CALL TGET
  261.          IF LEFT$(B$,1) = "N" or B$ = "n" THEN _
  262.             GOTO 64700
  263.       GOTO 64725
  264.       END IF
  265.  
  266. ' *****************************************************************************
  267. ' *  DISPLAY THE BALLOT                                                       *
  268. ' *****************************************************************************
  269.  
  270. 64715 CALL QTPUT ("Ballot choices (Vote 0 to quit without voting)",2)
  271.       FOR I = 1 TO CHOICES
  272.          I$ = "(" + RIGHT$(STR$(I),LEN(STR$(I))-1) + ") "
  273.          CALL QTPUT(I$ + CHOICE$(I),1)
  274.       NEXT
  275.       CALL QTPUT ("------------------------------------------------------",1)
  276.  
  277. ' *****************************************************************************
  278. ' *  GET THE CALLER'S VOTE                                                    *
  279. ' *****************************************************************************
  280.  
  281. 64720 A$ =  "Your vote (1 -" + STR$(CHOICES) + " )"
  282.       SUBROUTINE.PARAMETER = 1
  283.       CALL TGET
  284.       VOTE = VAL(LEFT$(B$,2))
  285.       IF VOTE = 0 THEN _
  286.          EXIT SUB
  287.       IF VOTE > CHOICES THEN _
  288.          CALL QTPUT ("Incorrect choice. Try again ...",1): _
  289.          GOTO 64720
  290.       OPEN VOTE.USER$ FOR APPEND AS #2
  291.       WRITE #2, ACTIVE.USER.NAME$
  292.       CLOSE 2
  293.       CHOICE.TOTAL(VOTE) = CHOICE.TOTAL(VOTE) + 1
  294.  
  295. ' *****************************************************************************
  296. ' *  UPDATE THE VOTE COUNT, DISPLAY RESULTS, AND UPDATE VOTE.COUNT$ FILE      *
  297. ' *****************************************************************************
  298.  
  299. 64725 TOTAL.VOTES = 0
  300.       FOR I = 1 TO CHOICES
  301.          TOTAL.VOTES = TOTAL.VOTES + CHOICE.TOTAL(I)
  302.       NEXT
  303.       CALL QTPUT ("Current Voting Results:" + SPACE$(40) + "Votes   Pct ",1)
  304.       CALL QTPUT ("-----------------------" + SPACE$(40) + "-----  -----",1)
  305.       FOR I = 1 TO CHOICES
  306.          I$ = "[" + RIGHT$(STR$(I),LEN(STR$(I))-1) + "]"
  307.          I$ = I$ + SPACE$(5-(LEN(I$)))
  308.          I$ = I$ + CHOICE$(I) + SPACE$(56-LEN(CHOICE$(I)))
  309.          I$ = I$ + SPACE$(6-LEN(STR$(CHOICE.TOTAL(I))))
  310.          I$ = I$ + STR$(CHOICE.TOTAL(I))
  311.          IF CHOICE.TOTAL(I) > 0 THEN
  312.             J$ = STR$(INT((CHOICE.TOTAL(I)/TOTAL.VOTES)*100)) + "%"
  313.          ELSE
  314.             J$ = STR$(0) + "%"
  315.          END IF
  316.          I$ = I$ + SPACE$(7-LEN(J$)) + J$
  317.          CALL QTPUT (I$,1)
  318.       NEXT
  319.       CALL QTPUT ("",1)
  320.       CALL QTPUT ("Total votes on this ballot = " + STR$(TOTAL.VOTES),1)
  321.       CALL QTPUT ("",1)
  322.       OPEN VOTE.COUNT$ FOR OUTPUT AS #2
  323.       FOR I = 1 TO CHOICES
  324.          WRITE #2, CHOICE$(I), CHOICE.TOTAL(I)
  325.       NEXT
  326.       CLOSE 2
  327.       A$ = "Vote on another ballot ([Y],N)"
  328.       SUBROUTINE.PARAMETER = 1
  329.       CALL TGET
  330.       IF B$ = "n" OR B$ = "N" THEN _
  331.          EXIT SUB
  332.       GOTO 64700
  333.       END SUB             ' END OF VOTE SUBPROGRAM
  334.  
  335.  
  336. '  $SUBTITLE: 'Error Handling for separately compiled subroutines'
  337. '  $PAGE
  338. '
  339. ' *****************************************************************************
  340. ' *  Error handling for the separately compiled subroutines of RBBS-PC        *
  341. ' *****************************************************************************
  342. '
  343. 65000 IF DEBUG THEN _
  344.  
  345.  
  346.  
  347. ------------------------------- END OF VOTE171A.DOC ---------------------------
  348.